
const componentConfigs = {
  getStore: () => { return '' }
}
const colors = ['#3bafff', '#3feed4', '#ff7f50', '#da70d6', '#32cd32', '#6495ed', '#ff69b4', '#ba55d3', '#cd5c5c', '#ffa500', '#40e0d0']
function getInitValue (value) {
  if (value && value.startsWith('$store')) {
    const res = componentConfigs.getStore(value)
    // const props = value.split('.')
    // let res = window.$store
    // for (let i = 0; i < props.length; i++) {
    //   if (props[i] === '$store') {
    //     continue
    //   }
    //   res = res[props[i]]
    // }
    return res
  }
}
function getPieChart ({ data, title, sum }) {
  return {
    title: {
      text: '{val|' + sum + '}\n{name|' + title + '}',
      top: 'center',
      left: 'center',
      textStyle: {
        rich: {
          name: {
            fontSize: 14,
            fontWeight: 'normal',
            color: '#666666',
            padding: [10, 0]
          },
          val: {
            fontSize: 18,
            fontWeight: 'bold',
            color: '#333333'
          }
        }
      }
    },
    grid: {
      bottom: 150,
      left: 0,
      right: '10%'
    },
    legend: {
      show: false,
      orient: 'vertical',
      top: 'middle',
      right: '5%',
      textStyle: {
        color: '#f2f2f2',
        fontSize: 25

      },
      icon: 'roundRect'
    },
    tooltip: {
      confine: true
    },
    series: [
      // 主要展示层的
      {
        color: colors,
        radius: ['65%', '80%'],
        center: ['50%', '50%'],
        type: 'pie',
        labelLine: {
          normal: {
            show: false
          }
        },
        label: {
          normal: {
            show: false
          }
        },
        data: data
      }

    ]
  }
}
function getProcess ({ data, title, sum, color }) {
  return {
    title: {
      text: '{val|' + sum + '}\n{name|' + title + '}',
      top: 'center',
      left: 'center',
      textStyle: {
        rich: {
          name: {
            fontSize: 14,
            fontWeight: 'normal',
            color: '#666666',
            padding: [10, 0]
          },
          val: {
            fontSize: 18,
            fontWeight: 'bold',
            color: '#333333'
          }
        }
      }
    },
    polar: { radius: ['70%', '80%'], center: ['50%', '50%'] },
    angleAxis: { max: 100, show: false },
    radiusAxis: { type: 'category', show: false, axisLabel: { show: false }, axisLine: { show: false }, axisTick: { show: false } },
    series: [{
      name: '',
      type: 'bar',
      roundCap: true,
      showBackground: true,
      backgroundStyle: { color: '#f7f7f7' },
      data: data,
      coordinateSystem: 'polar',
      itemStyle: { color: color }
    }]
  }
}
export {
  getInitValue, getPieChart, getProcess
}
